package demo.standard;

public class NonTerminalExpression extends AbstractExpression {
    AbstractExpression typeExpression;
    AbstractExpression nameExpression;

    public NonTerminalExpression(AbstractExpression typeExpression, AbstractExpression nameExpression) {
        this.typeExpression = typeExpression;
        this.nameExpression = nameExpression;
    }

    @Override
    public boolean interpreter(Context context) {
        String data = context.getData();
        String[] arr = data.split(" ");
        if (arr.length != 2) {
            return false;
        }
        return typeExpression.interpreter(new Context(arr[0])) && nameExpression.interpreter(new Context(arr[1]));
    }
}
